package com.flong.juc.charter1;

/**
 * @Author:liangjl
 * @Date: 2020/7/4-20:51
 * @Eamil:jilongliang@sina.com
 * @Description:
 *
 * interrupt 打断，不是真正的结束线程，在当前线程中打上一个停止的标记。
 * Thread 类提供了interrupted方法测试当前线程是否已经中断，isInterrupted方法测试线程是否已经中断
 */
public class MyTest5 {

    public static void main(String[] args) {
        Thread thread = new MyTest5Thread();
        thread.start();
        thread.interrupt();

        System.out.println("是否停止1=" + thread.isInterrupted());
        System.out.println("是否停止2=" + Thread.interrupted());


    }
}

class MyTest5Thread extends Thread {
    @Override
    public void run() {
        for (int i = 0; i < 10000; i++) {
            System.out.println("i=" + i);
        }
    }
}
